<form action="{{action}}" method="POST"  enctype="multipart/form-data">
<input type="hidden" name="TABLE" value="{{fields.TABLE}}"/>
<table border="0" style="margin: 0px auto;">
<tr><td><h1>COLUMNS</h1></td><td><h1>Actions</h1></td><td><h1>Debug info</h1></td></tr>
<tr><td style="vertical-align: top;">
	<table border="0" class="table">
	{{foreach c in columns}}
		{{if c.csv}}<tr><td><input type="checkbox" name="COLUMN-{{c.name}}" checked value="1"/></td><td>{{c.name}}</td></tr>{{/if}}
	{{/foreach}}
	</table>
</td><td style="vertical-align: top; width: 300px;">
	<select name="mode">
		<option value="export">EXPORT TO CSV</option>
		<option value="import">IMPORT FROM CSV</option>
	</select><br/>
	<input type="file" name="csv"/><br/>
	<input class="submit" type="submit" value="OK"/>
	<div>Import rules:</div>
	<div>If no column <b>id</b> was selected, it does <b>insert</b></div>
	<div>If column <b>id</b> was selected, it checks if entry by this <b>id</b> exists and does <b>update</b> or <b>insert</b>. Never does <b>delete</b>.</div>
</td><td style="vertical-align: top;">
	{{if columns_skipped.length}}
	<table border="0" class="table">
	<tr><th colspan="2">Skipped columns</th></tr>
	<tr><th>Name</th><th>Datatype</th></tr>
	{{foreach c in columns_skipped}}
	<tr><td>{{c.name}}</td><td>{{c.datatype}}</td></tr>
	{{/foreach}}
	</table>
	{{/if}}
</td></tr>
</table>
</form>

<h1 style="text-align: center;">Table {{fields.TABLE}}</h1>
<table border="0" class="table" style="margin: 0px auto;">
<tr>
	{{foreach c in columns}}{{if c.ok}}<th>{{c.name}}</th>{{/if}}{{/foreach}}<th></th>
</tr>
{{r}}
</table>
<br/><br/>
<table border="0" class="table" style="margin: 0px auto;">
<tr>
<td>Pages:</td>{{unless pages}}<td>All {{cnt}} entries shown</td>{{/unless}}
{{if pages}}
{{foreach p in pages}}<td><a href="{{action}}?mode=list&TABLE={{fields.TABLE}}&page={{p}}">{{p}}</a></td>{{each 50:49}}</tr><tr><td></td>{{/each}}{{/foreach}}
{{/if}}
</tr>
</table>
<script>
$(".submit").button({});
</script>

